#!/usr/bin/env python

from misc import subst_taskgen

class substpc_taskgen(subst_taskgen):
    def __init__(self, type='none'):
        subst_taskgen.__init__(self, None)
        self.version= ''
        self.uselib = ''
        self.inst_var='PREFIX'
        self.inst_dir='lib/pkgconfig'

    def get_private(self):
        priv = ''
        for i in self.to_list(self.uselib):
            for path in self.env['CPPPATH_'+i]:
                priv += '-L%s ' % path
            for lib in self.env['LIB_'+i]:
                priv += '-l%s ' % lib
        return priv

    def apply(self):
        self.dict = {'prefix' : self.env['PREFIX'], 
                     'exec_prefix' : '${prefix}',
                     'libdir' : '${exec_prefix}lib',
                     'includedir' : '${prefix}include',
                     'VERSION' : self.version,
                     'LIBS' : '-L${libdir} -l%s' % self.name,
                     'LIBS_PRIVATE' : self.get_private(),
                     'DFLAGS' : '-I${includedir}/d'}
        subst_taskgen.apply(self)
